
TRIGGER PROCEDURE FOR WRITE OF VO_MSTR OLD BUFFER OLD_VO_MSTR.

    {mfdeclre.i }
    define new shared work-table wf_old_vo_mstr like vo_mstr.

/* fdn 2009/06/29 Modify Record processing */
HK:
do:
    if can-find(first dt_mstr where dt_table = "vo_mstr" and dt_type = "SYNC") then
        run CreateSyncFlag(input "MOD", input recid(vo_mstr), input "vo_mstr").

    if not can-find ( first dt_mstr where dt_table = "vo_mstr" and dt_type = "MOD" ) then leave HK.
    
    if not can-find ( first wf_old_vo_mstr ) then do:
        create wf_old_vo_mstr.
        if recid(wf_old_vo_mstr)= -1 then .
    end.
    
    buffer-copy old_vo_mstr to wf_old_vo_mstr no-error.

    for each dt_mstr no-lock where dt_table = "vo_mstr" and dt_type = "MOD" :
    
        case dt_field :

            when "vo_ref" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo_ref, input vo_mstr.vo_ref,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_cr_terms" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo_cr_terms, input vo_mstr.vo_cr_terms,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_invoice" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo_invoice, input vo_mstr.vo_invoice,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_applied" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_applied), input string(vo_mstr.vo_applied),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_disc_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_disc_date), input string(vo_mstr.vo_disc_date),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_due_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_due_date), input string(vo_mstr.vo_due_date),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_hold" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_hold), input string(vo_mstr.vo_hold),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_paid_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_paid_date), input string(vo_mstr.vo_paid_date),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_amt_chg" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_amt_chg), input string(vo_mstr.vo_amt_chg),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_disc_chg" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_disc_chg), input string(vo_mstr.vo_disc_chg),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_po" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo_po, input vo_mstr.vo_po,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_receiver" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo_receiver, input vo_mstr.vo_receiver,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_ndisc_amt" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_ndisc_amt), input string(vo_mstr.vo_ndisc_amt),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_hold_amt" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_hold_amt), input string(vo_mstr.vo_hold_amt),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_cmtindx" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_cmtindx), input string(vo_mstr.vo_cmtindx),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_curr" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo_curr, input vo_mstr.vo_curr,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_ex_rate" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_ex_rate), input string(vo_mstr.vo_ex_rate),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_user1" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo_user1, input vo_mstr.vo_user1,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_separate" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_separate), input string(vo_mstr.vo_separate),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_ship" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo_ship, input vo_mstr.vo_ship,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo__chr01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo__chr01, input vo_mstr.vo__chr01,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo__chr02" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo__chr02, input vo_mstr.vo__chr02,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo__chr03" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo__chr03, input vo_mstr.vo__chr03,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo__chr04" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo__chr04, input vo_mstr.vo__chr04,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo__chr05" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo__chr05, input vo_mstr.vo__chr05,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo__dte01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo__dte01), input string(vo_mstr.vo__dte01),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo__dte02" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo__dte02), input string(vo_mstr.vo__dte02),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo__dec01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo__dec01), input string(vo_mstr.vo__dec01),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo__dec02" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo__dec02), input string(vo_mstr.vo__dec02),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo__log01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo__log01), input string(vo_mstr.vo__log01),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_tax_pct[1]" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_tax_pct[1]), input string(vo_mstr.vo_tax_pct[1]),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_type" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo_type, input vo_mstr.vo_type,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_confirmed" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_confirmed), input string(vo_mstr.vo_confirmed),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_conf_by" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo_conf_by, input vo_mstr.vo_conf_by,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_po_rcvd" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_po_rcvd), input string(vo_mstr.vo_po_rcvd),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_prepay" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_prepay), input string(vo_mstr.vo_prepay),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_tax_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_tax_date), input string(vo_mstr.vo_tax_date),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_modok" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_modok), input string(vo_mstr.vo_modok),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_user2" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo_user2, input vo_mstr.vo_user2,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_tax_env" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo_tax_env, input vo_mstr.vo_tax_env,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_recur" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_recur), input string(vo_mstr.vo_recur),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_rcycle" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo_rcycle, input vo_mstr.vo_rcycle,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_rnbr_cyc" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_rnbr_cyc), input string(vo_mstr.vo_rnbr_cyc),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_rstart" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_rstart), input string(vo_mstr.vo_rstart),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_rexpire" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_rexpire), input string(vo_mstr.vo_rexpire),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_rel_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_rel_date), input string(vo_mstr.vo_rel_date),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_rv_nbr" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo_rv_nbr, input vo_mstr.vo_rv_nbr,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_lc_amt" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_lc_amt), input string(vo_mstr.vo_lc_amt),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo__qad01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo__qad01, input vo_mstr.vo__qad01,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo__qad02" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo__qad02, input vo_mstr.vo__qad02,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo__qad03" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo__qad03), input string(vo_mstr.vo__qad03),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_is_ers" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_is_ers), input string(vo_mstr.vo_is_ers),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_taxable" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_taxable), input string(vo_mstr.vo_taxable),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_taxc" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo_taxc, input vo_mstr.vo_taxc,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_tax_usage" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo_tax_usage, input vo_mstr.vo_tax_usage,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_ex_rate2" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_ex_rate2), input string(vo_mstr.vo_ex_rate2),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_ex_ratetype" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vo_mstr.vo_ex_ratetype, input vo_mstr.vo_ex_ratetype,
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_base_applied" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_base_applied), input string(vo_mstr.vo_base_applied),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_base_amt_chg" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_base_amt_chg), input string(vo_mstr.vo_base_amt_chg),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_base_disc_chg" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_base_disc_chg), input string(vo_mstr.vo_base_disc_chg),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_base_ndisc" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_base_ndisc), input string(vo_mstr.vo_base_ndisc),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_base_hold_amt" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_base_hold_amt), input string(vo_mstr.vo_base_hold_amt),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_exru_seq" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_exru_seq), input string(vo_mstr.vo_exru_seq),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_waiting_exp" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_waiting_exp), input string(vo_mstr.vo_waiting_exp),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

            when "vo_resale_amt" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vo_mstr.vo_resale_amt), input string(vo_mstr.vo_resale_amt),
                    input recid(vo_mstr), input vo_mstr.vo_ref, input "", input "", input "",
                    input "", input "", input "", input "").

        end.

    end.
end.

{hkdttrans.i}
